define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user_course/index' + location.search,
                    add_url: 'user_course/add',
                    edit_url: 'user_course/edit',
                    del_url: 'user_course/del',
                    multi_url: 'user_course/multi',
                    import_url: 'user_course/import',
                    table: 'user_course',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
               // showSearch: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate: false},
                        //{field: 'venue_id', title: __('Venue_id')},
                        {field: 'term_id', title: __('Term_id'),addclass: 'selectpage', extend:'data-source="ajax/term"',visible:false},
                        {field: 'term.name', title: __('Term.name'), operate: false},
                        {field: 'order_no', title: __('订单号')},
                        {field: 'course.name', title: __('Course.name'), operate: false},
                        //{field: 'course_id', title: __('Course_id')},
                        //{field: 'user_id', title: __('User_id')},
                        {field: 'user.username', title: __('User.username'), operate: false},
                       // {field: 'coach_id', title: __('Coach_id')},
                        {field: 'time', title: __('Time'),  operate: false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                       // {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
                        {field: 'coach_score', title: __('Coach_score'),  operate: false},
                       /* {field: 'ext', title: __('Ext'), operate: 'LIKE'},*/
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')},visible:false, defaultValue:0, formatter: Table.api.formatter.status},
                        //{field: 'venue.name', title: __('Venue.name'), operate: 'LIKE'},



                       // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});